package com.example.springboot.mapper;

import com.example.springboot.entity.notifications;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface notificationsMapper {

    // 根据用户 ID 获取通知列表
    @Select("SELECT * FROM notifications WHERE user_id = #{user_id}")
    List<notifications> findByUserId(@Param("user_id") int user_id);

    // 标记通知为已读
    @Update("UPDATE notifications SET read_status = 'read' WHERE notification_id = #{notification_id}")
    void markAsRead(@Param("notification_id") int notification_id);

    // 获取通知的读取状态
    @Select("SELECT read_status FROM notifications WHERE notification_id = #{notification_id}")
    String getReadStatus(@Param("notification_id") int notification_id);
}